package client.comm.baoding.adapter

import android.content.Context
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import client.comm.baoding.R
import client.comm.baoding.api.bean.GoodsOrder
import client.comm.baoding.api.bean.Zcjl
import client.comm.baoding.databinding.ItemRechargeOrderBinding
import client.comm.baoding.databinding.LayoutOrderitemBinding
import client.comm.commlib.base.BaseLoadmoreAdapter
import client.comm.commlib.base.BindingViewHoder
import com.bumptech.glide.RequestManager

class RechargeOrderAdapter : BaseLoadmoreAdapter<Zcjl.Record> {

    val manager: RequestManager

    constructor(context: Context, manager: RequestManager) : super(context) {
        this.manager = manager
    }

    override fun createVh(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return BindingViewHoder(
            DataBindingUtil.inflate(
                layoutInflater,
                R.layout.item_recharge_order,
                parent,
                false
            )
        )
    }

    override fun bindVh(holder: RecyclerView.ViewHolder, position: Int) {
        val bindingViewHolder = holder as BindingViewHoder<ViewDataBinding>
        val binding = bindingViewHolder.binding as ItemRechargeOrderBinding
        val bean = getItem(position)
        binding.bean = bean
        binding.event = this
//        when (bean.status) {
//            0 -> {
//                binding.status = "待付款"
//            }
//            1 -> {
//                binding.status = "已完成"
//            }
//        }

//        val time = bean.create_time.substring(
//            5,
//            bean.create_time.length - 3
//
//        )
//        binding.time = time

    }


    fun itemClick(bean: GoodsOrder.Order) {
//        context.startActivity(Intent(context, GoodsOrderDetailActivity::class.java).apply {
//            putExtra("bean", bean)
//        })
    }


//    fun goTUiKuan(bean: GoodsOrder.Order) {
//        context.startActivity(Intent(context, ApplyTuiKuanActivity::class.java).apply {
//            putExtra("bean", bean)
//        })
//    }

    var orderPay: ((bean: Zcjl.Record) -> Unit)? = null

    fun goPay(bean: Zcjl.Record) {
        orderPay?.invoke(bean)
    }

    var cancle: ((bean: Zcjl.Record) -> Unit)? = null

    fun cancleOrder(bean: Zcjl.Record) {
        cancle?.invoke(bean)
    }

}